<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px" style="display: flex;padding: 20px;">
      <el-form-item label="订单编号" prop="OrderNumber">
        <el-input
          v-model="queryParams.OrderNumber"
          placeholder="请输入订单编号"
          clearable
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange">
      <el-table-column label="序号" align="center" prop="id"
        ><template slot-scope="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="订单编号" align="center" prop="orderNumber" />
      <el-table-column label="奶茶名称" align="center" prop="goodsName" />
      <el-table-column label="价格" align="center" prop="price"/>
      <el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
    </el-table>
  </div>
</template>

<script>
import { orderList } from "@/api/getData.js"
export default {
  name: "Circuit",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      postList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
      },
     
      // 表单参数
      form: {},
       // 用户导入参数
      // 表单校验
      uploadFileUrl:'/api/food/uploadFile',
      fileWay: [],
      tableHeight:0
    };
  },
  created() {
    this.getList()
  },
  mounted(){
    let that = this;
    this.$nextTick(() => {
      that.tableHeight = document.documentElement.clientHeight - 85 + "px";
      window.onresize = () => {
        return (() => {
          that.tableHeight = document.documentElement.clientHeight - 85 + "px";
        })();
      };
    });
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      if(!this.queryParams.OrderNumber){
        this.queryParams = {}
      }
      orderList(this.queryParams).then(response => {
        this.postList = response.data;
        this.loading = false;
      });
    },
  
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
  
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.postId)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
  
  }
  
};
</script>
